<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      canvas {
        display: block;
        margin: 0 auto;
      }
    </style>
  </head>
  <body>
    <script>
      //   const canvas = document.createElement("canvas");
      //   canvas.width = 800;
      //   canvas.height = 600;
      //   document.body.append(canvas);
      //   const context = canvas.getContext("2d");

      const v = document.createElement("video");
      v.width = 800;
      v.height = 600;
      document.body.append(v);

      navigator.mediaDevices
        .getUserMedia({ audio: true, video: true })
        .then((value) => {
          //   value.getVideoTracks()
          v.srcObject = value;
          v.play();
        })
        .catch((err) => console.log(err));
    </script>
  </body>
</html>
